namespace MuseumApp.Data.Migrations
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;
    using MuseumApp.Data.Models;

    internal sealed class Configuration : DbMigrationsConfiguration<MuseumApp.Data.MuseumDbContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
        }

        protected override void Seed(MuseumApp.Data.MuseumDbContext context)
        {
            //Prepopulate three museums
            context.Museums.AddOrUpdate(
                m => m.Name,
                new Museum { MuseumId = 1, Name = "MOMA", City = "L.A.", Description = "Museum of Modern Art" },
                new Museum { MuseumId = 2, Name = "Space and Air Museum", City = "D.C.", Description = "Astronomy" },
                new Museum { MuseumId = 3, Name = "International Spy Museum", City = "D.C.", Description = "Spies and Espionage" }
            );
            context.SaveChanges();

            //Prepopulate a review for each museum
            context.Reviews.AddOrUpdate(
                r => r.Comment,
                new Review { Username = "Joe", Rating = 8, Comment = "Really great!", MuseumId = 1 },
                new Review { Username = "Shelby", Rating = 10, Comment = "Super cool!", MuseumId = 2 },
                new Review { Username = "Steve", Rating = 9, Comment = "So mysterious...", MuseumId = 3 },
                new Review { Username = "Shelby", Rating = 8, Comment = "I loved it!", MuseumId = 3 }
            );
            context.SaveChanges();
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //
        }
    }
}
